<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <style>
        .box1{
            width: 300px;
            height: 300px;
            background: lightgreen;
        }
        .box2{
            width: 200px;
            height: 200px;
            background: rgb(144, 200, 238);
        }
    </style>
</head>
<body>
    <div id="app">
        <!-- <div class="box1" @click='clickBox1'>
            <div class="box2"  @click.stop='clickBox2'></div>   -->
            <!-- 阻止冒泡事件   -->
        <!-- </div> -->



        <a href="https://www.baidu.com" @click.prevent='clickA'>点我</a>



        <!-- <div class="box1" @click='clickBox1'>
            <div class="box2"  @click.capture='clickBox2'></div>   -->
            <!-- 捕获   -->
         <!-- </div> -->



         <div class="box1" @click.self='clickBox1'>
            <div class="box2"  @click='clickBox2'></div>  
            <!-- 捕获   -->
         </div>


         <button @click.once=initData>初始化了数据</button>
    </div>
    <script>
        const vm =new Vue({
            el:'#app',
            data:{

            },
            methods:{
                clickBox1(){
                    console.log('点击了外层盒子');
                },
                clickBox2(){
                    console.log('点击了内层盒子');
                },
                clickA(){
                    console.log('跳转');
                },
                initData(){
                    console.log('初始化了数据');
                }
            }

        })
    </script>
</body>
</html>